package com.probiz.estore.common.model.catalog.base;

import java.io.Serializable;
import com.probiz.estore.Constants;
import com.probiz.estore.common.model.catalog.VirtualCategory;
import com.probiz.estore.common.model.product.Product;
import com.probiz.estore.core.model.BaseObject;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;

/**
 * VirtualcatProdRelation Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 */
public class VirtualcatProdRelationTbl extends BaseObject implements Serializable {

    protected Integer virtualcatProdRelationId;
	protected Product product;
    protected VirtualCategory virtualCategory;
    protected Integer sortOrder;


    /**
	 * Default Empty Constructor for class VirtualcatProdRelation
	 */
	public VirtualcatProdRelationTbl () {
		super();
	}
	
	/**
	 * Default Key Fields Constructor for class VirtualcatProdRelation
	 */
	public VirtualcatProdRelationTbl (
		 Integer in_virtualcatProdRelationId
        ) {
		this.setVirtualcatProdRelationId(in_virtualcatProdRelationId);
    }

	
	public VirtualCategory getVirtualCategory () {
		return virtualCategory;
	}	
	
	public void setVirtualCategory (VirtualCategory in_virtualCategory) {
		this.virtualCategory = in_virtualCategory;
	}

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    /**
	 * 	 * @return Integer
     * @hibernate.id column="virtualcatProdRelationId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getVirtualcatProdRelationId() {
		return this.virtualcatProdRelationId;
	}
	
	/**
	 * Set the virtualcatProdRelationId
	 */	
	public void setVirtualcatProdRelationId(Integer aValue) {
		this.virtualcatProdRelationId = aValue;
	}	

	/**
	 * 专场目录id	 * @return Integer
	 */
	public Integer getCategoryId() {
		return this.getVirtualCategory()==null?null:this.getVirtualCategory().getCategoryId();
	}
	
	/**
	 * Set the categoryId
	 */	
	public void setCategoryId(Integer aValue) {
	    if (aValue==null) {
	    	virtualCategory = null;
	    } else {
	        virtualCategory = new VirtualCategory(aValue);
	        virtualCategory.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}	

	/**
	 * 商品id	 * @return Integer
	 */
	public Integer getProductId() {
		return this.getProduct()==null?null:this.getProduct().getProductId();
	}

	/**
	 * Set the productId
	 */
	public void setProductId(Integer aValue) {
	    if (aValue==null) {
	    	product = null;
	    } else {
	        product = new Product(aValue);
	        product.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
	    }
	}

	/**
	 * 排序值，一般值越小，越靠前	 * @return Integer
	 * @hibernate.property column="sortOrder" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getSortOrder() {
		return this.sortOrder;
	}
	
	/**
	 * Set the sortOrder
	 */	
	public void setSortOrder(Integer aValue) {
		this.sortOrder = aValue;
	}	

	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof VirtualcatProdRelationTbl)) {
			return false;
		}
		VirtualcatProdRelationTbl rhs = (VirtualcatProdRelationTbl) object;
		return new EqualsBuilder()
				.append(this.virtualcatProdRelationId, rhs.virtualcatProdRelationId)
				.append(this.sortOrder, rhs.sortOrder)
				.isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.virtualcatProdRelationId) 
				.append(this.sortOrder)
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("virtualcatProdRelationId", this.virtualcatProdRelationId) 
				.append("sortOrder", this.sortOrder) 
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "virtualcatProdRelationId";
	}
	
	/**
	 * Return the Id (pk) of the entity, must be Integer
	 */
	public Integer getId() {
		return virtualcatProdRelationId;
	}

}